package com.xls.boxlibrary.tixianjilu;


import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.core.content.ContextCompat;
import androidx.viewpager.widget.ViewPager;
import androidx.viewpager2.widget.ViewPager2;

import com.google.android.material.tabs.TabLayout;
import com.xls.boxlibrary.Consts.IntentConsts;
import com.xls.boxlibrary.R;
import com.xls.boxlibrary.customcontrol.StatusBarHeightView;
import com.xls.boxlibrary.mvp.MVPBaseActivity;


/**
 * MVPPlugin
 */

public class TiXianJiLuActivity extends MVPBaseActivity<TiXianJiLuContract.View, TiXianJiLuPresenter> implements TiXianJiLuContract.View, View.OnClickListener {

    private TextView title_text;
    private ImageView title_back;
    private RelativeLayout title_rl_content;
    private RelativeLayout title_rl;
    private ViewPager2 tixianjilu_list;
    private TextView tab1;
    private TextView tab2;
    private LinearLayout tabLayout;

    public static void startActivity(Activity activity,String appid) {
        Intent intent=new Intent(activity, TiXianJiLuActivity.class);
        intent.putExtra(IntentConsts.id,appid);
        activity.startActivity(intent);
    }

    @Override
    public int getView() {
        return R.layout.activity_tixianjilu;
    }

    @Override
    public void initView() {
        title_text = findViewById(R.id.title_text);
        title_back = findViewById(R.id.title_back);
        title_rl_content = findViewById(R.id.title_rl_content);
        tixianjilu_list = findViewById(R.id.tixianjilu_list);
        title_back.setOnClickListener(this);
        title_text.setText("提现记录");
        setAdapter();
        title_rl = findViewById(R.id.title_rl);
        tab1 = findViewById(R.id.tab1);
        tab2 = findViewById(R.id.tab2);
        tabLayout = findViewById(R.id.tabLayout);
        tab1.setOnClickListener(this);
        tab2.setOnClickListener(this);
        tixianjilu_list.setUserInputEnabled(false);
        setpostion(0);
    }

    private void setpostion(int position) {
        if (position==0){
            tab1.setBackgroundResource(R.drawable.bg_cirlce_ffcb2d_ff8236);
            tab1.setTextColor(ContextCompat.getColor(getContext(),R.color.white));
            tab2.setBackgroundResource(R.drawable.bg_white_50);
            tab2.setTextColor(ContextCompat.getColor(getContext(),R.color.text_black));
        }else {
            tab1.setBackgroundResource(R.drawable.bg_white_50);
            tab1.setTextColor(ContextCompat.getColor(getContext(),R.color.text_black));
            tab2.setBackgroundResource(R.drawable.bg_cirlce_ffcb2d_ff8236);
            tab2.setTextColor(ContextCompat.getColor(getContext(),R.color.white));
        }
    }

    private void setAdapter() {
        tixianjilu_list.setAdapter(mPresenter.getViewPageAdapter());
    }

    @Override
    public void onClick(View view) {
        int id = view.getId();
        if (id == R.id.tab1) {
            tixianjilu_list.setCurrentItem(0);
            setpostion(0);
        } else if (id == R.id.tab2) {
            tixianjilu_list.setCurrentItem(1);
            setpostion(1);
        }else if (view.getId() == R.id.title_back) {
            finish();
        }
    }
}
